---
title: "Environments & Git Sync"
description: ""
icon: "git-alt"
---

<Snippet file="enterprise-feature.mdx" />

The Git Sync feature allows for the creation of an **external backup**, **environments**, and maintaining a **version history**.


### How It Works:

This example explains a simple setup for creating development and production environments. The setup can be extended to include multiple environments and multiple Git branches.

**Requirements:**
- Empty Git Repository
- Two Projects in Activepieces: one for Development and one for Production.

#### 1. Push Flow to the repository

After making changes in the flow, You click on arrow near the flow name and select "Push to Git", Add commit and push.

#### 2. Deleting a Flow from the Repository

When you delete a flow from a project that has the project configured on the development branch, it will also automatically delete the flows from Git.


#### 3. Pull from the Repository

<Note>
Please note that the credentials will not be synced automatically. You should manually create identical credentials with the same names in both environments.
</Note>

You can trigger a pull from the Git Repository button in Activepieces. This action will replace all flows in the project with those from the git repository.

- All flows that are enabled in production will be updated and republished, If a flow fails to republish, a new version will be created as a draft.
- All flows that are **not** in the git repository will be deleted.
- New flows created in production will be disabled by default.

#### Approval Workflow (Optional)

To manage your approval workflow, you can use Git by creating two branches: development and production. Then, you can use standard pull requests as the approval step.

#### GitHub action
This GitHub action can be used to automatically pull changes upon merging.

<Tip>
Don't forget to replace `INSTANCE_URL` and `PROJECT_ID`, and add `ACTIVEPIECES_API_KEY` to the secrets.
</Tip>

```yml
name: Auto Deploy
on:
  workflow_dispatch:
  push:
    branches: [ "main" ]
jobs:
  run-pull:
    runs-on: ubuntu-latest
    steps:
      - name: deploy
        # Use GitHub secrets
        run: |
          curl --request POST \
            --url {INSTANCE_URL}/api/v1/git-repos/pull \
            --header 'Authorization: Bearer ${{ secrets.ACTIVEPIECES_API_KEY }}' \
            --header 'Content-Type: application/json' \
            --data '{
              "projectId": "{PROJECT_ID}"
            }'
```